package com.ant.storage.controller;


import com.ant.storage.common.ResultVo;
import com.ant.storage.pojo.Payment;
import com.ant.storage.service.IPaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author melon
 * @since 2022-10-20
 */
@RestController
@RequestMapping("/payment")
@Api(tags = "请款接口")
public class PaymentController {

    @Autowired
    private IPaymentService paymentService;

    @ApiOperation(value = "保存")
    @PostMapping("/savePayment")
    public ResultVo savePayment(@RequestBody @Valid Payment payment, BindingResult bindingResult) throws Exception {
        return paymentService.savePayment(payment, bindingResult);
    }

    @ApiOperation(value = "请款通过")
    @GetMapping("/PaymentAdopt/{id}")
    public ResultVo PaymentAdopt(@PathVariable(value = "id",required = false) Integer id) {
        if(id==null){
            return ResultVo.fail("id不能为空");
        }
        return paymentService.PaymentAdopt(id);
    }

}
